package com.cfpamf.athean.rabbit.mq.plus.common.exception;

import java.io.PrintStream;
import java.io.PrintWriter;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * <p>
 * Description: Service exception 基类,所有Service实现类异常均由此类派生
 * </p>
 * 
 * @version 1.0
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class RabbitMqPlusException extends RuntimeException {

    /**
    * 
    */
    private static final long serialVersionUID = -7074796630261537939L;
    private Throwable nestedThrowable = null;

    public RabbitMqPlusException() {
        super();
    }

    public RabbitMqPlusException(String message) {
        super(message);
    }

    public RabbitMqPlusException(Throwable nestedThrowable) {
        super(nestedThrowable);
        this.nestedThrowable = nestedThrowable;
    }

    public RabbitMqPlusException(String message, Throwable nestedThrowable) {
        super(message, nestedThrowable);
        this.nestedThrowable = nestedThrowable;
    }

    @Override
    public void printStackTrace() {
        super.printStackTrace();
        if (nestedThrowable != null) {
            nestedThrowable.printStackTrace();
        }
    }

    @Override
    public void printStackTrace(PrintStream ps) {
        super.printStackTrace(ps);
        if (nestedThrowable != null) {
            nestedThrowable.printStackTrace(ps);
        }
    }

    @Override
    public void printStackTrace(PrintWriter pw) {
        super.printStackTrace(pw);
        if (nestedThrowable != null) {
            nestedThrowable.printStackTrace(pw);
        }
    }
}
